﻿using SCG.General;
using System;
using System.Collections.Generic;

namespace SCG.SolarVengeanceEngine.BrainInfo
{
    //Represents map objects visible to Brains
    public class SVObjectInfo
    {
        //constructor
        public SVObjectInfo(SVMapObject svm)
        {
            _svm = svm;
        }

        //The object's location
        public SCGPoint Location
        {
            get
            {
                return _svm.Location;
            }
        }
        public int X
        {
            get
            {
                return (int)Location.X;
            }
        }
        public int Y
        {
            get
            {
                return (int)Location.Y;
            }
        }

        //adjacent?
        public bool IsAdjacentTo(SVObjectInfo o)
        {
            return Math.Abs(X - o.X) <= 1 && Math.Abs(Y - o.Y) <= 1;
        }

        //private members
        private SVMapObject _svm;

        //access the map object
        internal SVMapObject MapObject
        {
            get
            {
                return _svm;
            }
        }

        //for use by specific brains
        public object BrainData
        {
            get
            {
                if (_brainData == null)
                    _brainData = new Dictionary<Brain, object>();
                if (_brainData.ContainsKey(BrainExecuting))
                    return _brainData[BrainExecuting];
                else
                    return null;
            }
            set
            {
                if (_brainData == null)
                    _brainData = new Dictionary<Brain, object>();
                _brainData[BrainExecuting] = value;
            }
        }

        //which brain is currently executing?
        public static Brain BrainExecuting = null;

        //private members
        private Dictionary<Brain, object> _brainData;
    }
}
